#include <cstddef>
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;
struct Node {
  int l;
  int r;
  Node(int x, int y) : l(x), r(y) {}
};
vector<Node> nums(110, Node(0, 0));
int findLca(int root, int l, int r) {
    if(!root || root == l || root == r) {
        return root;
    }
    int left = findLca(nums[root].l, l, r);
    int right = findLca(nums[root].r, l, r);
    if(left && right) {
        return root;
    }
    return left ? left : right;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    if (!nums[x].l) {
      nums[x].l = y;
    } else if (!nums[x].r) {
      nums[x].r = y;
    }
  }
  int x, y;
  cin >> x >> y;
  int u, v, w;
  int lca = findLca(1, x, y);
  size_t size = 0;
  int depth = 0;
  queue<int> q;
  q.push(1);
  while (!q.empty()) {
    depth++;
    queue<int> t;
    while (!q.empty()) {
      int temp = q.front();
      if(temp == lca) {
        u = depth;
      }
      if(temp == x) {
        v = depth;
      }
      if(temp == y) {
        w = depth;
      }
      q.pop();
      if (nums[temp].l) {
        t.push(nums[temp].l);
      }
      if(nums[temp].r) {
        t.push(nums[temp].r);
      }
    }
    q = t;
    size = max(size, t.size());
  }
  cout << depth << endl;
  cout << size << endl;
  cout << (v - u) * 2 + (w - u) << endl;
  return 0;
}